﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CustomRedirects.aspx.cs" Inherits="EPiBoost.Core.Plugins.Gui.Admin.CustomRedirects" %>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Custom Redirects manager</title>
    
    <%
        var cmsPath = EPiServer.Configuration.Settings.Instance.UIUrl.ToString();
        var shellPath = cmsPath.Replace("/CMS/", "/Shell/");
    %>

	<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    <link rel="stylesheet" type="text/css" href="<%= ResolveUrl(shellPath + "1.0.456/ClientResources/epi/themes/legacy/ShellCore.css") %>" />
    <script type="text/javascript" src="<%= ResolveUrl(shellPath + "1.0.456/ClientResources/ShellCore.js") %>"></script>
    <link rel="stylesheet" type="text/css" href="<%= ResolveUrl(shellPath + "1.0.456/ClientResources/epi/themes/legacy/ShellCoreLightTheme.css") %>" />
    <script type="text/javascript" src="<%= ResolveUrl(cmsPath  + "1.0.431/ClientResources/ReportCenter/ReportCenter.js") %>"></script>
    <link type="text/css" rel="stylesheet" href="<%= ResolveUrl(cmsPath + "1.0.431/ClientResources/Epi/Base/CMS.css") %>" />
        

    <style type="text/css">
 
        .row{clear:both; height:2.5em;}
        label {width:140px !important; display:block; float:left;}
        input {float:left; margin-right:30px; width:250px}
        .selected{font-weight:bold;}
        .float-right{ float: right;}
        .importMessage{ clear: both;color: red;display: block;font-size: 1.5em;}
    </style>

</head>
<body>
    <form id="form1" runat="server">    
        <div class="epi-contentContainer epi-padding" style="max-width:100%">
        <div class="epi-contentArea">
            <h1>Custom Redirects <%=EPiBoost.Core.Configuration.Core.CustomRedirects.Enabled ? "" : "(Disabled)" %></h1>
             
            <p><a href="?" class="<%= Request["unhandled"]==null ? "selected" : "" %>">Handled URLs</a> 
           <%-- | <a href="?unhandled=1" class="<%= Request["unhandled"]==null ? "" : "selected" %>">Unhandled URLs</a>--%>
            | <a href="?add=1" >Add new redirect</a>
                
                <span class="float-right"><a href="?export=true">Export</a> | <a href="?import=true" >Import</a>
                <span class="importMessage"><%=Request.QueryString["importMessage"] %></span>
                </span>
            </p>
            
            <asp:PlaceHolder runat="server" ID="plhEdit" Visible="false" >
                <div class="epi-formArea">
                    <fieldset >
                        <legend>Edit</legend>
                        <div class="row">
                            <asp:Label ID="Label1" runat="server"  AssociatedControlID="txtOldUrl">Old URL</asp:Label>
                            <asp:TextBox runat="server" ID="txtOldUrl" />
                            
                            <asp:Label ID="Label2" runat="server"   AssociatedControlID="chkStart">Match partial URL</asp:Label>
                            <asp:CheckBox runat="server" ID="chkStart" />
                            
                            <asp:Label ID="Label5" runat="server"   AssociatedControlID="chkOverride">Override Existing Urls</asp:Label>
                            <asp:CheckBox runat="server" ID="chkOverride" />
                            

                       </div>
                       <div class="row">
                            <asp:Label ID="Label3" runat="server"  AssociatedControlID="txtNewUrl">New URL</asp:Label>
                            <asp:TextBox runat="server" ID="txtNewUrl" />
                
                            <asp:Label ID="Label4" runat="server"   AssociatedControlID="chkAppend">Append request URL</asp:Label>
                            <asp:CheckBox runat="server" ID="chkAppend" />
                           
                            <asp:Label ID="Label8" runat="server"   AssociatedControlID="chkQuerystring">Maintain Querystring</asp:Label>
                            <asp:CheckBox runat="server" ID="chkQuerystring" />
                       </div>

                       <div class="epi-buttonDefault">
                        <span class="epi-cmsButton">
                        <asp:Button runat="server" ID="btnSave" Text="Save" CssClass="epi-cmsButton-text epi-cmsButton-tools epi-cmsButton-Save" OnClick="btnSave_Click" />
                        </span>
                        <span class="epi-cmsButton">
                        <asp:Button runat="server" ID="btnCancel" Text="Cancel" CssClass="epi-cmsButton-text epi-cmsButton-tools epi-cmsButton-Cancel" OnClick="btnCancel_Click" />
                        </span>
                       </div>
                    </fieldset>
                </div>
            </asp:PlaceHolder>
            
            
            <asp:PlaceHolder runat="server" ID="plhImport" Visible="false" >
                <div class="epi-formArea">
                    <fieldset >
                        <legend>Import</legend>
                        <div class="row">
                            <asp:Label ID="Label6" runat="server"  AssociatedControlID="txtOldUrl">Import File</asp:Label>
                           <asp:FileUpload runat="server" ID="fluImport"/>
                         
                           <asp:Label ID="Label7" runat="server"   AssociatedControlID="chkStart">Overwrite Existing</asp:Label>
                           <asp:CheckBox runat="server" ID="chkImportOverwrite"/> 
                       </div>

                       <div class="epi-buttonDefault">
                        <span class="epi-cmsButton">
                        <asp:Button runat="server" ID="btnImportSave" Text="Save" CssClass="epi-cmsButton-text epi-cmsButton-tools epi-cmsButton-Save" OnClick="btnImportSave_Click" />
                        </span>
                        <span class="epi-cmsButton">
                        <asp:Button runat="server" ID="btnImportCancel" Text="Cancel" CssClass="epi-cmsButton-text epi-cmsButton-tools epi-cmsButton-Cancel" OnClick="btnImportCancel_Click" />
                        </span>
                       </div>
                    </fieldset>
                </div>
            </asp:PlaceHolder>


            <br /><br />

            <asp:Repeater runat="server" ID="rptRedirects" Visible="false">
                <HeaderTemplate>
                <table>
                    <tbody>
                        <tr>
                            <th>Old URL</th>
                            <th>Match partial</th>
                            <th>Override Existing</th>
                            <th>New URL</th>
                            <th>Append URL</th> 
                            <th>Maintain Querystring</th> 
                            <th></th>
                            <th></th>
                        </tr>
                </HeaderTemplate>

                <ItemTemplate>
                    <tr>
                        <td><%# Eval("OldUrl") %></td>
                        <td><%# Eval("MatchStart")%></td>
                        <td><%# Eval("OverrideExisting")%></td>
                        <td><%# Eval("NewUrl")%></td>
                        <td><%# !(bool)Eval("WildCardSkipAppend")%></td> 
                        <td><%# (bool)Eval("MaintainQuerystring")%></td> 
                        <td><a href="?edit=1&oldurl=<%# Server.UrlEncode((string)Eval("OldUrl")) %>">Edit</a></td>
                        <td><a href="?delete=1&oldurl=<%# Server.UrlEncode((string)Eval("OldUrl")) %>" onclick="return confirm('Are you sure?')">Remove</a></td>
                    </tr>
                </ItemTemplate>

                <FooterTemplate>
                    </tbody>
                </table>
                </FooterTemplate>
            </asp:Repeater>

        </div>
        </div>
    </form>
</body>
</html>